/*****************************************************************************
*
*  PROJECT:		
*               
*  LICENSE:		
*
*  DEVELOPER:	
*
*****************************************************************************/

#include "EonTexture.h"

Eon::Texture::Texture( const char *filename )
{
	m_filename = filename;
	glbmp_t bitmap;
	GLuint texture;

	glbmp_LoadBitmap( m_filename, 0, &bitmap );

	glGenTextures(1, &texture);
	glBindTexture(GL_TEXTURE_2D, texture);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); // Clamp to edge to remove seams of skybox
	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, bitmap.width, bitmap.height, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmap.rgb_data);
	glbmp_FreeBitmap(&bitmap);

	m_ID = texture;
}

void Eon::Texture::bindTexture( void )
{
	glBindTexture( GL_TEXTURE_2D, m_ID );
}

